<!DOCTYPE html>
<html lang="zh-cn">
	<head>
	    <meta charset="utf-8">
	    <meta http-equiv="X-UA-Compatible" content="IE=edge">
	    <meta name="viewport" content="width=device-width, initial-scale=1">
	    <title></title>
	    <#include "/common/meta.ftl"/>
		<script>
			$(function(){
				$("#btnSearch").click(function(){
					if($('#query').val()=='请输入关键字'){
						$('#query').val('');
					}
					$("#page").val(1);
					$('#form')[0].submit();
				});	
				<#if (flag!'')!=''>
				var msg = new top.$.zui.Messager('提示消息：${flag!''}', {
		                	type : 'success',
		                	fade : true,
		                	icon : 'ok-sign',
		                	time : 3000,
		                	scale : true
		    	});
				msg.show();
				</#if>
			});
			function update(roleId,type){
				var operation = 1;
				if(type){
					operation = 1;
				}else{
					operation = 0;
				}
				$.getJSON("roleUserJSave", { type:operation,userId: '${userId}', roleId: roleId }, function(json){
					if(json.success){
						var msg = new top.$.zui.Messager('提示消息：'+json.msg, {
		                	type : 'success',
		                	fade : true,
		                	icon : 'ok-sign',
		                	time : 3000,
		                	scale : true
		                });
		                msg.show();
					}
				});
			}
		</script>
	</head>
	<body style="padding:5px;">
			<form id="form" class="form-horizontal" role="form" method='post' action="./grantRoleByUser?userId=${userId}">
		          		<table style="width:100%;margin-bottom:5px;">
		          			<tr>
		          				<td>
		          					<strong>当前用户【${userName!''}】</strong>
		          				</td>
		          				<td width="400px" align=right>
		          					<div class="input-group" style="width:190px;">
		          						<span class="input-group-addon fix-border">角色名称</span>
		          						<input type="text" id="roleName" name="roleName" value="${roleName!''}" class="form-control" style="width:120px;"/>
		          						<span class="input-group-btn">
		          							<button class="btn btn-primary" id="btnSearch" name="btnSearch" type="button"><i class="icon icon-search"></i> 查询</button>
		          						</span>
		          					</div>
		          				</td>
							</tr>
						</table>	             	
				<table class="table table-hover table-bordered table-condensed" style="margin:0px;">
				  	<thead>
				    	<tr>
					      	<th style="width:50px;text-align:center;">选择</th>
					      	<th style="width:50px;text-align:center;">序号</th>
					      	<th style="text-align:center;width:120px;">角色名称</th>
					      	<th style="text-align:center;">角色简介</th>
					      	<th style="text-align:center;width:80px;">排序</th>
					      	<th style="text-align:center;width:80px;">状态</th>
				    	</tr>
				  	</thead>
					<tbody>
				<#list data.records as x>
	  			<tr>
	  				<td style="text-align:center">
	  					<input type="checkbox" class="CK" <#if (x.userSelected!'')==userId>checked</#if> onclick="update('${x.roleID!''}',this.checked)" />
	  				</td>
	  				<td style="text-align:center">${x_index+1}</td>
			      	<td style="text-align:center">
			      	${x.roleName?default('')}			      	
			      	</td>
			      	<td style="text-align:left">${x.roleMemo?default('')}</td>
			      	<td style="text-align:center">${x.roleOrder?default('')}</td>
			      	<td style="text-align:center">
				      	<#if x.roleStatus?exists&&x.roleStatus==1>
				      	<span style=color:green><b>正常</b></span>
				      	<#elseif x.roleStatus?exists&&x.roleStatus==11>
				      	<span style=color:orange><b>未激活</b></span>
				      	<#else>
				      	<span style=color:red><b>已停用</b></span>
				      	</#if>
			      	</td>
			    </tr>
			    </#list>
					</tbody>
				</table>
			<#include "/common/page_v1.ftl"/>
	    	</form>
	</body>
</html>
